Skip to content
This repository has been archived by the owner on Apr 23, 2021. It is now read-only.

Fix the wrong computation of dynamic strides for lowering AllocOp to LLVM #338

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

tungld
Copy link

@tungld tungld commented Dec 24, 2019

The computation of dynamic strides in lowering AllocOp was wrong.

Given a MemRefType with sizes = [5, 10], it computed strides = [5, 1], while the correct answer should be strides = [10, 1].

River707 and others added 3 commits December 23, 2019 21:09
MSVC has trouble resolving the static 'printOptionValue' from the method on llvm::cl::opt/list. This change renames the static method to avoid this conflict.

PiperOrigin-RevId: 286978351
Copy link
Contributor

@ftynse ftynse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! There's one extra simplification that can be made to make the code cleaner.

@@ -1054,14 +1054,15 @@ struct AllocOpLowering : public LLVMLegalizationPattern<AllocOp> {
// Iterate strides in reverse order, compute runningStride and strideValues.
auto nStrides = strides.size();
SmallVector<Value, 4> strideValues(nStrides, nullptr);
for (auto indexedStride : llvm::enumerate(llvm::reverse(strides))) {
for (auto indexedStride : llvm::enumerate(strides)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, enumerate is useless here, the body of the loop never accesses indexedStride.value(). Could you just rewrite the loop to iterate on index to remove the confusion that led to the bug in the first place?

@tungld
Copy link
Author

tungld commented Dec 28, 2019

Thanks, @ftynse! I removed enumerate.

ftynse pushed a commit to llvm/llvm-project that referenced this pull request Dec 28, 2019
…cOp to LLVM

Leftover change from before the MLIR merge, reviewed at accepted at
tensorflow/mlir#338.
@ftynse
Copy link
Contributor

ftynse commented Dec 28, 2019

Landed as llvm/llvm-project@e5957ac.

Since MLIR moved to LLVM, please submit your following contributions through https://reviews.llvm.org. Thank you!

@joker-eph could you please close?

bondhugula pushed a commit to bondhugula/llvm-project that referenced this pull request Jan 7, 2020
…cOp to LLVM

Leftover change from before the MLIR merge, reviewed at accepted at
tensorflow/mlir#338.
arichardson pushed a commit to arichardson/llvm-project that referenced this pull request Jan 20, 2020
…cOp to LLVM

Leftover change from before the MLIR merge, reviewed at accepted at
tensorflow/mlir#338.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants